<template>
  <div class="all-home">
    <div class="carousel-container">
      <el-carousel arrow="always">
        <el-carousel-item v-for="item in 5" :key="item"> </el-carousel-item>
      </el-carousel>
      <!-- 为您推荐 -->
      <div class="tj3-top"></div>
      <div class="tj3-bottom">
        <div class="tj3-container">
          <ul class="tj3-nav">
            <li class="tj3-product" v-for="(item, index) in products">
              <div class="product-left" @click="toDetailsPage(item._id)">
                <h3 class="til">{{ item.productName }}</h3>
                <p class="tag">{{ item.productInfo }}</p>
                <p class="time" v-if="item.ontime == 60 * 60 * 24">
                  承保期限：24 小时
                </p>
                <p class="time" v-if="item.ontime == 60 * 60 * 24 * 7">
                  承保期限：7 天
                </p>
                <p class="time" v-if="item.ontime == 60 * 60 * 24 * 30">
                  承保期限：30 天
                </p>
                <p class="time" v-if="item.ontime == 60 * 60 * 24 * 365">
                  承保期限：1 年
                </p>
                <div class="zuhe">
                  <span class="price-box">
                    ￥
                    <span class="price">{{ item.price }}</span>
                    <span class="qi">起</span>
                  </span>
                  <a href="javascript:void(0);">
                    立即投保
                    <i></i>
                  </a>
                </div>
              </div>
              <div class="product-right">
                <img
                  src="../../assets/images/3df9d556-c744-4319-a837-529fa25e29e9.png"
                />
              </div>
            </li>
          </ul>
        </div>
      </div>
      <!-- 探索优质保险 -->
      <div class="explore-insurance">
        <div class="explore-insurance-contanir">
          <h2>探索优质保险</h2>
          <div class="explore-insurance-describe">
            <div class="explore-left">
              <span class="pull-left">精选热销产品</span>
              <span class="pull-right">绝不能错过的质量产品</span>
            </div>
            <a href="#">寻找适合我的保险></a>
          </div>
          <div class="explore-insurance-main">
            <div class="explore-insurance-item">
              <div class="explore-insurance-img-box">
                <div class="img-pic">
                  <img src="../../assets/images/tsyzbx_RWX.jpg" />
                </div>
              </div>
              <div class="message">
                <p class="op1">学校不再代办意外险，少儿意外不可忽视</p>
                <p>涵盖意外身故、伤残 意外医疗 重大疾病</p>
                <span> 阅读更多 </span>
              </div>
            </div>
            <div class="explore-insurance-item oitem2">
              <div class="explore-insurance-img-box">
                <div class="img-pic">
                  <img src="../../assets/images/tsyzbx_BK2.png" />
                </div>
              </div>
              <div class="message">
                <p class="op1">意外身故、伤残最高50万</p>
                <p>交通意外最高500万</p>
                <p>扩展高风险运动最高50万 最低65元起</p>
                <span> 阅读更多 </span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 寻找贴心服务 -->
      <div class="finding-service">
        <div class="finding-service-contanir">
          <h2>寻找贴心服务</h2>
          <div class="finding-service-describe">
            <div class="server-left">
              <span class="pull-left">热门服务</span>
              <span class="pull-right">86%的用户用过如下服务</span>
            </div>
            <a href="#">寻找我需要的服务></a>
          </div>
          <div class="finding-service-main">
            <div class="finding-service-item">
              <div class="server-img">
                <a href="#">
                  <img src="../../assets/images/image1.png" />
                </a>
              </div>
              <div class="server-message">
                <a href="#">
                  <h4>保单查询</h4>
                </a>
                <p>多种方式轻松查找您的保单信息，全方位掌握您的保障情况</p>
              </div>
            </div>
            <div class="finding-service-item">
              <div class="server-img">
                <a href="#">
                  <img src="../../assets/images/image2.png" />
                </a>
              </div>
              <div class="server-message">
                <a href="#">
                  <h4>理赔查询</h4>
                </a>
                <p>
                  一站式查询您名下所有保单的理赔信息，第一时间了解赔案处理进度
                </p>
              </div>
            </div>
            <div class="finding-service-item">
              <div class="server-img">
                <a href="#">
                  <img src="../../assets/images/gwHotSeviceKF.png" />
                </a>
              </div>
              <div class="server-message">
                <a href="#">
                  <h4>洋洋客服</h4>
                </a>
                <p>
                  太平洋保险智能客服，7*24小时随时为您服务，满足您的服务需求
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="my_safe">
      <div class="my_safe_unlogin">
        <div class="touxiang"></div>
        <h3 class="username">Hi,您好</h3>
        <router-link class="log-in" tag="a" to="/login">登录</router-link>
        <router-link class="sign-in" tag="a" to="/register">注册</router-link>
      </div>
    </div>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
  "homePage"
);
export default {
  created() {
    this.getProducts();
    this.getMessage(localStorage._id);
  },
  computed: {
    ...mapState(["products"]),
    top6Products() {
      return this.products.slice(0, 6);
    },
  },
  methods: {
    ...mapMutations(["setId"]),
    ...mapActions(["getProducts", "getMessage"]),
    toDetailsPage(_id) {
      this.setId(_id);
      this.$router.push({
        name: "DetailsPage",
        query: {
          _id,
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.all-home {
  position: relative;
  .my_safe {
    width: 208px !important;
    height: 206px;
    padding-top: 0;
    position: absolute;
    right: 15%;
    top: 56px;
    border-radius: 5px;
    box-shadow: 0 4px 17px 0 rgba(159, 159, 159, 0.53);
    z-index: 999;
    .my_safe_unlogin {
      width: 208px !important;
      height: 206px;
      background: url("../../assets/images/denglubeijing.png") center
        center/100% 100% no-repeat;
      position: relative;
      padding-top: 72px;
      .touxiang {
        background: url("../../assets/images/morentouxiang.png") center
          center/100% 100% no-repeat;
        width: 59px;
        height: 59px;
        position: absolute;
        top: -28px;
        left: 74px;
        border-radius: 59px;
        overflow: hidden;
      }
      .username {
        text-align: center;
        font-size: 14px;
        color: #262626;
        letter-spacing: 0;
      }
      .log-in {
        display: block;
        width: 126px;
        height: 32.5px;
        margin: 0 auto;
        text-align: center;
        /* margin-top: 18px; */
        margin-top: 15px;
        line-height: 32.5px;
        background: #005bac;
        box-shadow: 0 2px 5px 0 #84c0f5;
        border-radius: 17px;
        font-size: 14px;
        color: #ffffff;
        letter-spacing: 0;
        cursor: pointer;
        text-decoration: none;
      }
      .sign-in {
        display: block;
        width: 126px;
        height: 32.5px;
        margin: 0 auto;
        text-align: center;
        margin-top: 15px;
        line-height: 32.5px;
        background: #fff;
        border: 1px solid #005bac;
        border-radius: 17px;
        font-size: 14px;
        color: #005bac;
        letter-spacing: 0;
        cursor: pointer;
        text-decoration: none;
      }
    }
  }
}
.carousel-container {
  .el-carousel__item:nth-child(6) {
    background: url("../../assets/images/53007_1920x398.jpg");
    background-position: center top;
    background-size: cover;
    overflow: hidden;
  }
  .el-carousel__item:nth-child(7) {
    background: url("../../assets/images/53031_1920x398.png");
    background-position: center top;
    background-size: cover;
    overflow: hidden;
  }
  .el-carousel__item:nth-child(3) {
    background: url("../../assets/images/53037_1920x398.jpg");
    background-position: center top;
    background-size: cover;
    overflow: hidden;
  }
  .el-carousel__item:nth-child(4) {
    background: url("../../assets/images/53039_1920x398.png");
    background-position: center top;
    background-size: cover;
    overflow: hidden;
  }
  .el-carousel__item:nth-child(5) {
    background: url("../../assets/images/53053_1920x398.png");
    background-position: center top;
    background-size: cover;
    overflow: hidden;
  }
}
.tj3-top {
  width: 499px;
  height: 38px;
  margin: 20px auto;
  background: url("../../assets/images/tj3Til.png") center center/100% 100%
    no-repeat;
}
.tj3-bottom {
  background-color: rgb(244, 244, 244);
  padding: 10px 0;
  .tj3-container {
    width: 1148px;
    margin: 0 auto;
    .tj3-nav {
      list-style: none;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      .tj3-product {
        width: 550px;
        height: 183px;
        display: flex;
        background: #ffffff;
        border: 2px solid #e7e7e7;
        box-shadow: 0 5px 8px 0 #f1f1f1;
        border-radius: 4px;
        padding: 12px 16px 8px 28px;
        margin-bottom: 20px;
        .product-left {
          width: 335px;
          .tag {
            font-size: 15px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          .time {
            font-size: 13px;
            color: #9f9f9f;
            letter-spacing: 0;
            line-height: 20px;
            margin-top: 6px;
          }
          .zuhe {
            display: flex;
            justify-content: space-between;
            align-items: center;
            .price-box {
              font-size: 17.16px;
              color: #e93e4e;
              letter-spacing: 0;
              text-align: center;
              line-height: 22.88px;
              font-weight: 600;
            }
            a {
              font-size: 15px;
              color: #333333;
              font-weight: 600;
              display: block;
              width: 118px;
              height: 31px;
              border-radius: 20px;
              text-align: center;
              line-height: 31px;
              text-decoration: none;
              margin-right: 15px;
              i {
                display: inline-block;
                width: 21px;
                height: 21px;
                background: url("../../assets/images/tj3Xuebi.png") -20px 0px/200px
                  200px no-repeat;
                margin-left: 7px;
                position: relative;
                top: 5px;
              }
            }
          }
        }
        .product-right {
          width: 171px;
          height: 158px;
          overflow: hidden;
          border-radius: 5px;
          img {
            width: 100%;
            height: 100%;
            display: block;
          }
        }
        &:hover {
          transition: 1.5s;
          border: 2px solid rgb(0, 91, 172);
        }
        &:hover .product-left .zuhe a {
          transition: 1.5s;
          background-color: rgb(0, 91, 172);
          color: white;
        }
        &:hover .product-right img {
          transition: 1.5s;
          transform: scale(1.2);
        }
      }
    }
  }
}
.explore-insurance {
  width: 100%;
  padding-top: 50px;
  .explore-insurance-contanir {
    width: 1148px;
    background: #fff;
    margin: 0 auto;
    h2 {
      text-align: center;
      font-size: 44px;
      font-weight: 500;
      letter-spacing: 2px;
    }
    .explore-insurance-describe {
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .explore-left {
        .pull-left {
          font-size: 18px;
          letter-spacing: 0;
        }
        .pull-right {
          color: #4a4a4a;
          font-size: 16px;
          margin-top: 2px;
          letter-spacing: 0;
          margin-left: 4px;
        }
      }
      a {
        font-size: 16px;
        margin-top: 2px;
        color: #1565c0;
        text-decoration: none;
      }
    }
  }
  .explore-insurance-main {
    width: 1148px;
    overflow: hidden;
    height: 460px;
    display: flex;
    .explore-insurance-item {
      width: 420px;
      height: 380px;
      margin: 45px 34px 0;
      border: 1px solid #e6e6e6;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
      position: relative;
      margin-right: 10px;
      .explore-insurance-img-box {
        overflow: hidden;
        .img-pic {
          width: 418px;
          height: 170px;
          overflow: hidden;
          img {
            height: 171px;
          }
        }
      }
      .message {
        .op1 {
          margin-top: 50px;
        }
        p {
          padding: 0 30px;
          color: #7a7a7a;
          font-size: 14px;
          font-weight: 100;
        }
        span {
          position: absolute;
          right: 38px;
          bottom: 20px;
          color: #1565c0;
        }
      }
      &:hover {
        transition: 1.5s;
        box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
      }
      &:hover .explore-insurance-img-box .img-pic img {
        transition: 1.5s;
        transform: scale(1.2);
      }
    }
    .oitem2 {
      width: 320px;
    }
  }
}
.finding-service {
  margin-top: 60px;
  background: url("../../assets/images/Background1.png") 100% 100%;
  height: 580px;
  border-top: 1px solid white;
  .finding-service-contanir {
    width: 1148px;
    margin: 0 auto;
    h2 {
      text-align: center;
      font-size: 44px;
      font-weight: 500;
      letter-spacing: 2px;
      color: #fff;
    }
    .finding-service-describe {
      margin-top: 23px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: #fff;
      letter-spacing: 2px;
      .server-left {
        .pull-left {
          font-size: 18px;
          letter-spacing: 0;
        }
        .pull-right {
          font-weight: 100;
          margin-top: 2px;
          font-size: 16px;
          letter-spacing: 0;
          margin-left: 4px;
        }
      }
      a {
        color: #fff;
        letter-spacing: 2px;
        font-size: 12px;
        text-decoration: none;
      }
    }
    .finding-service-main {
      display: flex;
      justify-content: space-between;
      .finding-service-item {
        width: 33%;
        margin-top: 56px;
        .server-img {
          a {
            img {
              width: 163px;
              border-radius: 50%;
              box-shadow: 0 5px 25px 0 rgba(0, 0, 0, 0.3);
              display: block;
              margin: 0 auto;
            }
          }
        }
        .server-message {
          a {
            font-size: 18px;
            margin-top: 42px;
            letter-spacing: 4px;
            width: 280px;
            text-align: center;
            color: #fff;
            text-decoration: none;
          }
          p {
            opacity: 0.7;
            margin-top: 20px;
            line-height: 28px;
            font-weight: 100;
            width: 280px;
            margin: 0 auto;
            text-align: center;
            color: #fff;
          }
        }
      }
    }
  }
}
</style>